package cn.anc.aonicardv.media;

import android.net.Network;
import android.view.View;

public class PlayerManager implements MediaOperation {

    private MediaOperation mediaOperation;
    private View playerView;

    public PlayerManager(MediaOperation mediaOperation) {
        this.mediaOperation = mediaOperation;
        if (mediaOperation == null)
            throw new IllegalArgumentException("MediaOperation no null");
    }

    @Override
    public void start() {
        mediaOperation.start();
    }

    @Override
    public void resume() {
        mediaOperation.resume();
    }

    @Override
    public void pause() {
        mediaOperation.pause();
    }

    @Override
    public void seekTo(long pos) {
        mediaOperation.seekTo(pos);
    }

    @Override
    public void setVolume(float volume) {
        mediaOperation.setVolume(volume);
    }

    @Override
    public int getDuration() {
        return mediaOperation.getDuration();
    }

    @Override
    public boolean isPlaying() {
        return mediaOperation.isPlaying();
    }

    @Override
    public int getCurrentPosition() {
        return mediaOperation.getCurrentPosition();
    }

    @Override
    public int getBufferPercentage() {
        return mediaOperation.getBufferPercentage();
    }

    @Override
    public void releasePlayer() {
        mediaOperation.releasePlayer();
    }

    @Override
    public void setAutoReconnect(boolean autoConnect) {
       mediaOperation.setAutoReconnect(autoConnect);
    }

    public void setNetwork(Network network) {
        mediaOperation.setNetwork(network);
    }

    @Override
    public void setDataSource(String url) {
        mediaOperation.setDataSource(url);
    }

    public void setMediaOperation(MediaOperation mediaOperation) {
        this.mediaOperation = mediaOperation;
    }

    public View getPlayerView() {
        return playerView;
    }
}
